package com.guoheng.hazard.sys.controller.hazard;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.hazard.KeyRegulatoryProcessInsertDTO;
import com.guoheng.hazard.sys.model.dto.hazard.KeyRegulatoryProcessUpdateDTO;
import com.guoheng.hazard.sys.service.hazard.KeyRegulatoryProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　KeyRegulatoryProcessController
 *
 * @author fbl
 * @date 2019-11-13 08:18
 */
@RestController
@Validated
@Api(value = "重点监管危险化工工艺信息表")
public class KeyRegulatoryProcessController {

    @Resource
    KeyRegulatoryProcessService keyRegulatoryProcessService;

    @ApiOperation(value = "查询企业重点监管危险化工工艺信息表")
    @GetMapping(value = "data/major/hazard/processes")
    public Result getProcesses(String entprName,String processName,Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return keyRegulatoryProcessService.getProcesses(entprName,processName,entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业重点监管危险化工工艺信息表")
    @PutMapping(value = "data/major/hazard/process")
    public Result updateProcesses(@RequestBody @Valid KeyRegulatoryProcessUpdateDTO keyRegulatoryProcessUpdateDTO) {
        return keyRegulatoryProcessService.updateProcesses(keyRegulatoryProcessUpdateDTO);
    }

    @ApiOperation(value = "新增企业重点监管危险化工工艺信息表")
    @PostMapping(value = "data/major/hazard/process")
    public Result insertProcesses(@RequestBody @Valid KeyRegulatoryProcessInsertDTO keyRegulatoryProcessInsertDTO) {
        return keyRegulatoryProcessService.insertProcesses(keyRegulatoryProcessInsertDTO);
    }

    @ApiOperation(value = "删除企业重点监管危险化工工艺信息表")
    @DeleteMapping(value = "data/major/hazard/process/{id}")
    public Result deleteProcesses(@PathVariable @NotNull Long id) {
        return keyRegulatoryProcessService.deleteProcesses(id);
    }

    @ApiOperation(value = "查询企业重点监管危险化工工艺信息详情")
    @GetMapping(value = "data/major/hazard/process/{id}")
    public Result selectProcessesById(@PathVariable @NotNull Long id) {
        return keyRegulatoryProcessService.selectProcessesById(id);
    }

    @ApiOperation(value = "统计高危工艺")
    @GetMapping(value = "data/major/hazard/process/statistics")
    public Result processesStatistics() {
        return keyRegulatoryProcessService.processesStatistics();
    }
}